﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wfCustomShopEditer.aspx.cs"
    Inherits="msBsc.WebUi.wfCustomShopEditer" %>
    
<!DOCTYPE HTML>
<html>
<head id="Head1" runat="server"> 
    <title>店铺装修设置</title>
    <link rel="shortcut icon" href="/themes/Style1/Image/favicon.ico"
        type="image/x-icon" />
    <link rel="stylesheet" href="/??themes/Style1/StyleQt.css,jqPlugin/kindeditor/themes/default/default.css,themes/Style1/Dealer.css" />
    <script src="/??jqPlugin/js/jquery-1.8.3.min.js,js/jBase.js,js/jBPage.js,themes/Style1/jsQt.js,jqPlugin/kindeditor/kindeditor.js,jqPlugin/kindeditor/lang/zh_CN.js,jqPlugin/js/laytpl.js"
        type="text/javascript"></script>
    <!--head fix rgn-->
    <style type="text/css">
         
        
#good_spec{  font-size:12px;}
#good_spec thead{ text-align:center;}
#good_spec td{padding:2px 4px; }
#good_spec td n{color:Red; font-weight:bold;}
#good_spec tr:hover{opacity:0.8; filter:Alpha(opacity=80);}

	        .textBox {
	            overflow:hidden;
	            border:1px solid silver;
	            display:inline-block;
	            padding:2px;
	            position:relative;
	                top:2px;
	        }
	
	            .textBox .text {
	                border:none;
	                height:20px;
	            }
	
	            .textBox a.sel-button {
	                display:block;
	                position:absolute;
	                width:20px;
	                height:20px;
	                border:0px solid silver;
	                top:2px;
	                right:2px;
	                background:url(/themes/Style1/Image/icon.gif) no-repeat center center;
	            }

    </style>
    <script type="text/javascript">
        K = KindEditor;
//        K.DEBUG = true;
        K.basePath = K.options.basePath = '/jqPlugin/kindeditor/';
        K.options.themesPath = K.options.basePath + 'themes/';
        K.options.langPath = K.options.basePath + 'lang/';
        K.options.pluginsPath = K.options.basePath + 'plugins/';
        function getfilequery() {
            return "&ParentId=" + $("#txtCurrDirId").val()
                                    + "&FileId=" + ""
                                    + "&RelId=" + ""
                                    + "&rType1=" + "1"
                                    + "&rType2=" + "0";
        };
        var editorHead;
        var editorContend;
        var editorSearch;
        var sheadhtml = '';
        var scontenthtml = '';
        var ssearchhtml = '';
        $(window).load(function () {
            $.ploadFile("layer", function (script, textStatus) {
                //                layer.load('加载中'); 
            });


            editorHead = K.create('#txtHeadTemplate', {
                allowFileManager: true,
                resizeType: 1,
                allowPreviewEmoticons: true,
                allowImageUpload: false,
                loadStyleMode: false,
                afterCreate: function () {
                    //                    editorHead.uploadJson = '/pgajax.axd?F_UPLOAD=1&blSave=1&COOKATHID=' + (typeof (cookesc) == "undefined" ? "" : cookesc)
                    //                                    + "&fType=" + "image"
                    //                                    + getfilequery();
                    //                    this.loadPlugin('autoheight');

                }
            });
            editorHead.sync("txtHeadTemplate");
            editorHead.html(sheadhtml);


            editorContend = K.create('#txtContentTemplate', {
                allowFileManager: true,
                resizeType: 1,
                allowPreviewEmoticons: true,
                allowImageUpload: false,
                loadStyleMode: false,
                afterCreate: function () {
                    //                    editorContend.uploadJson = '/pgajax.axd?F_UPLOAD=1&blSave=1&COOKATHID=' + (typeof (cookesc) == "undefined" ? "" : cookesc)
                    //                                    + "&fType=" + "image"
                    //                                    + getfilequery();
                    //                    this.loadPlugin('autoheight');

                }
            });
            editorContend.sync("txtContentTemplate");
            editorContend.html(scontenthtml);

            editorSearch = K.create('#txtSearchTemplate', {
                allowFileManager: true,
                resizeType: 1,
                allowPreviewEmoticons: true,
                allowImageUpload: false,
                loadStyleMode: false,
                afterCreate: function () {
                    //                    editorContend.uploadJson = '/pgajax.axd?F_UPLOAD=1&blSave=1&COOKATHID=' + (typeof (cookesc) == "undefined" ? "" : cookesc)
                    //                                    + "&fType=" + "image"
                    //                                    + getfilequery();
                    //                    this.loadPlugin('autoheight');

                }
            });
            editorSearch.sync("txtSearchTemplate");
            editorSearch.html(ssearchhtml);




            $('#J_logo_selectImage').click(function () {
                editorHead.loadPlugin('insertfile', function () {
                    editorHead.plugin.fileDialog({
                        fileUrl: $('#logo_img_selected img').attr('src'),
                        clickFn: function (url, title) {
                            $('#logo_img_selected').empty().html('<img alt="" src="' + url + '" for="' + url + '" width="100%" height="100%">');
                            editorHead.hideDialog();
                        }
                    });
                });
            });
            $('#J_head_selectImage').click(function () {
                editorHead.loadPlugin('insertfile', function () {
                    editorHead.plugin.fileDialog({
                        fileUrl: $('#head_img_selected img').attr('src'),
                        clickFn: function (url, title) {
                            $('#head_img_selected').empty().html('<img alt="" src="' + url + '" for="' + url + '" width="100%" height="100%"/>');
                            editorHead.hideDialog();
                        }
                    });
                });
            });


            $("#content_top_img tr").live("mouseover", function () { $(this).find(".spec-remove").show(); }).live("mouseout", function () { $(this).find(".spec-remove").hide(); });
            $("#content_top_img .spec-remove").live("click", function () { $(this).parent().parent().remove(); });
            $("#content_top_img .head-img-sel").live('click', function () {
                var $inp = $(this).prev();
                editorHead.loadPlugin('insertfile', function () {
                    editorHead.plugin.fileDialog({
                        fileUrl: $inp.val(),
                        clickFn: function (url, title) {
                            $inp.val(url);
                            editorHead.hideDialog();
                        }
                    });
                });
            });

            $("#ckbHeadCust").click(function () {
                if ($(this).attr("checked") == "checked" || $(this).attr("checked") == true) {
                    $("#divHeadTemplateEdit").show();
                    $("#divHeadTemplateEditdesc").show();
                } else {
                    $("#divHeadTemplateEdit").hide();
                    $("#divHeadTemplateEditdesc").hide();
                }
            });

            $("#ckbGoodsListCust").click(function () {
                if ($(this).attr("checked") == "checked" || $(this).attr("checked") == true) {
                    $("#divContentTemplate").show();
                    $("#divContentTemplatedesc").show();
                } else {
                    $("#divContentTemplate").hide();
                    $("#divContentTemplatedesc").hide();
                }
            });

            $("#ckbSearchCust").click(function () {
                if ($(this).attr("checked") == "checked" || $(this).attr("checked") == true) {
                    $("#divSearchTemplate").show();
                    $("#divSearchTemplatedesc").show();
                } else {
                    $("#divSearchTemplate").hide();
                    $("#divSearchTemplatedesc").hide();
                }
            });
        });
        function doBoundHeader(_shopurl) {
            if (_shopurl != null && _shopurl != undefined && _shopurl != '') {
                jQuery.loadHtml(_shopurl).done(function (_rethtml) {
                    var tpl = HtmlUtil.htmlDecode(_rethtml);
                    sheadhtml = tpl;
                    editorHead && editorHead.html(tpl); 
                });
            }
        };
        function loadSysHeadTemplate() {
            jQuery.loadHtml("/Template/SysShopHeader.html").done(function (_rethtml) { 
                editorHead.html(HtmlUtil.htmlDecode(_rethtml)); 
            }); 
        };
        function doBoundContent( _shopurl) {
            if (_shopurl != null && _shopurl != undefined && _shopurl != '') {
                jQuery.loadHtml(_shopurl).done(function (_rethtml) {
                    var tpl = HtmlUtil.htmlDecode(_rethtml);
                    scontenthtml = tpl;
                    editorContend && editorContend.html(tpl); 
                });
            }
        };
        function loadSysContentTemplate() {
            jQuery.loadHtml("/Template/SysShopGoodsList.html").done(function (_rethtml) {
                editorContend.html(HtmlUtil.htmlDecode(_rethtml));
            });
        };
        function doBoundSearch( _shopurl) {
            if (_shopurl != null && _shopurl != undefined && _shopurl != '') {
                jQuery.loadHtml(_shopurl).done(function (_rethtml) {
                    var tpl = HtmlUtil.htmlDecode(_rethtml);
                    ssearchhtml = tpl; 
                    editorSearch && editorSearch.html(tpl); 
                });
            }
        };
        function loadSysSearchTemplate() {
            jQuery.loadHtml("/Template/SysShopSearchList.html").done(function (_rethtml) {
                editorSearch.html(HtmlUtil.htmlDecode(_rethtml));
            });
        };
        function addHeadImg() {
            var str = "";
            str += "<tr data-id=\"\">";
            str += "<td>";
            str += '<span class="textBox" ><input type="text" class="text" class="need" value="" for="IMG_URL" style="width:300px;"/><a href="javascript:void(0);" class="sel-button head-img-sel"></a></span> ';
            str += "</td>";
            str += "<td>";
            str += "<input class=\"need\" for=\"BG_COLOR\" value=\"\" type=\"text\">";
            str += "</td>";
            str += "<td>";
            str += "<input class=\"need\" for=\"LINK_URL\" value=\"\" type=\"text\" style=\"width:200px;\">";
            str += "</td>";
            str += "<td style=\"border: 0;width:80px;\">";
            str += "<a style=\"display: none;\" class=\"spec-remove\" href=\"javascript:void(0);\" ></a>";
            str += "</td>";
            str += "</tr>";
            $('#content_top_img').append(str);
//            var $str = $(str);
//            var $tr = $("#good_spec  tr").eq(-1);
//            $tr.after($str);
            return false;
        };


        function getHeadImgForSave(_jsPost) {
            var $list1 = $('#content_top_img tr');
            $list1.each(function (i, GoodDetailItem) {
                var $self = $(this);
                _jsPost.AddCell("HEAD_IMG_ID" + '_' + i, $self.attr('data-id'));
                $self.find(" input").each(function (r, goodDetail) {
                    _jsPost.AddCell($(this).attr('for') + '_' + i, $(this).val());
                });
            });
            _jsPost.AddCell("HEAD_IMG_COUNT", $list1.length);
        };
        function doSaveSet() {
            var loadi = layer.load('正在保存中…');
            try {
                function closeload() { layer.close(loadi); }
                var _jsParam = new jsonRow();
                _jsParam.AddCell("ACTION", "doSaveSet"); 
                //获取数据
                var _jsPost = new jsonRow();
                getHeadImgForSave(_jsPost);
                _jsPost.AddCell("DEFAULT_HEADER_IMG_URL", $('#head_img_selected img').attr('src'));
                _jsPost.AddCell("LOGO_IMG_URL", $('#logo_img_selected img').attr('src'));
                _jsPost.AddCell("DEFAULT_HEADER_BG_COLOR", $('#txtDEFAULT_HEADER_BG_COLOR').val());
                _jsPost.AddCell("HEADER_SHOW_SHOP_NME", ($("#ckbHEADER_SHOW_SHOP_NME").attr("checked") == "checked" || $("#ckbHEADER_SHOW_SHOP_NME").attr("checked") == true));
                if ($("#ckbHeadCust").attr("checked") == "checked" || $("#ckbHeadCust").attr("checked") == true) {
                    _jsPost.AddCell("HEADER_TEMPLATE_HTML", editorHead.html());
                }
                if ($("#ckbGoodsListCust").attr("checked") == "checked" || $("#ckbGoodsListCust").attr("checked") == true) {
                    _jsPost.AddCell("GOODS_LIST_TEMPLATE_HTML", editorContend.html());
                }
                if ($("#ckbSearchCust").attr("checked") == "checked" || $("#ckbSearchCust").attr("checked") == true) {
                    _jsPost.AddCell("GOODS_SEARCH_TEMPLATE_HTML", editorSearch.html());
                }
                  
                ajaxComm(_jsParam, _jsPost, closeload);
            }
            catch (err) {
                layer.close(loadi);
            }
        };

    </script>
</head>
<body>
    <div id="mallPage" class="tms-page mallAct tmall-  page-not-market">
        <!-- -->
        <!--商城通用顶通-->
        <%=new msBsc.WebUi.Code.QtHtmlGet().GetHeaderTopHtml()%>
        <%=new msBsc.WebUi.Code.QtHtmlGet().GetHeaderLogoDealerHtml("商户管理")%>
        <div id="content" class="content" style=" padding-top: 10px;">
            <div class="page lang-zh-S">
                <div id="mytaobao-panel" class="grid-c2">
                    <div class="col-main" id="J_Col_Main" style="padding-bottom: 0;">
                        <div class="main-wrap">
                            <div id="main-content">
                                <div id="fragment1">

                                
                                <div style="border: 1px solid rgb(196, 213, 224); " id="div_goods_info"> 
                                    <div style="padding: 10px; background-color:#ffffff; ">
                                        <h3>
                                            1.店铺通用顶部装修</h3>
                                        <div style="width: auto;">
                                            <div style="height: auto;" class="cat_table">
                                                <div class="ilabel">
                                                    <span style=" font-weight:bold;">店铺LOGO：</span><br />
                                                    <div style=" padding:5px;">  
                                                        <input class="btn btn-mini btn-danger" id="J_logo_selectImage" type="button" value="选择图片" />
                                                    <p>190 x 120 (像素)</p>
                                                    </div></div>
                                                <div class="list" style="background-color: #ffffff;">
                                                    <div style="width: 194px; height: 124px; padding: 2px; margin-left: 10px; float: left;
                                                        background-color: #eee;" id="logo_img_selected">
                                                    </div>
                                                    <div style="margin: 10px; float: left; width: 200px;">
                                                        <p>
                                                           建议图片大小： 190 x 120 (像素)</p>
                                                    </div>
                                                </div>
                                            </div>
                                            <div style="height: auto;" class="cat_table">
                                                <div class="ilabel">
                                                    <span style=" font-weight:bold;">店铺顶部宣传图片：</span><br />
                                                    <div style=" padding:5px;">  
                                                        <input class="btn btn-mini btn-danger" id="J_head_selectImage" type="button" value="选择图片" />
                                                    <p>1190 x 130 (像素)</p>
                                                    <p>背景色 <input style="width: 50px;" id="txtDEFAULT_HEADER_BG_COLOR" type="text" class="sInt1" value=""/></p>
                                                    </div>
                                                    <label><b><input type="checkbox" id="ckbHEADER_SHOW_SHOP_NME"/></b><span style=" font-weight:bold;">是否显示店铺名称</span></label>
                                                    </div>
                                               
                                                <div class="list" style="background-color: #ffffff;">
                                                    <div style="width: auto; height: 134px; padding: 2px; margin-left: 10px; float: left;
                                                        background-color: #eee;" id="head_img_selected">
                                                    </div> 
                                                </div>
                                            </div>
                                            <div style="clear:both;"></div>
                                            <div style="height: auto;" class="cat_table">
                                                <div class="ilabel">
                                                    <label><b><input type="checkbox" id="ckbHeadCust"/></b><span style=" font-weight:bold;">店铺顶部整体自定义：</span></label><br />
                                                    <div style=" padding:5px;display:none;" id="divHeadTemplateEditdesc"> 
                                                    <a href="javascript:void(0);return false;" onclick="loadSysHeadTemplate();">导入系统模版</a>
                                                    <p>可以在模版中使用javascript代码</p>
                                                    </div>
                                                    </div>
                                                <div class="list"  style="background-color:#ffffff; ">
                                                <div id="divHeadTemplateEdit" style="display:none;">
                                                    <textarea name="txtHeadTemplate" id="txtHeadTemplate" style="width:883px; height: 200px; visibility: hidden;"></textarea>
                                            </div></div>
                                                 
                                            </div>
                                            <div style="clear:both;"></div>
                                            </div>
                                            
                                        <h3>
                                            2.店铺首页中部广告</h3>
                                        <div style="width: auto;">
                                            <div style="height: auto;" class="cat_table">
                                                <div class="ilabel">
                                                    <b></b><span style=" font-weight:bold;"> 首页广告图片设置：</span><br />
                                                    <div style=" padding:5px;">
                                    <input class="btn btn-mini btn-danger" id="Button1" type="button" onclick="addHeadImg();" value="添加图片和链接" /> 
                                                    <p>1190 x 500 (像素)</p>
                                                    </div></div>
                                                <div  id="good_spec" class="list">
                                                    <!-- 展示首页广告图片设置列表 -->
                                                    <table style="margin-left: 20px;" border="0px" cellpadding="0" cellspacing="0">
                                                        <thead>
                                                            <th align="center">
                                                                <tr>
                                                                    <td >
                                                                      <span style="width:120px;">  图片地址</span>
                                                                    </td>
                                                                    <td >
                                                                       <span style="width:120px;">  背景颜色</span>
                                                                    </td>
                                                                    <td>
                                                                       <span style="width:120px;">  链接地址</span>
                                                                    </td>
                                                                    <td style="border: 0; width: 200px;">
                                                                    </td>
                                                                </tr>
                                                                </th>
                                                        </thead>
                                                        <tbody id="content_top_img">
                                                        </tbody>
                                                    </table> 
                                                    <!-- END -->
                                                </div>
                                            </div> 
                                            </div>
                                            
                                        <h3>
                                            3.店铺首页底部橱窗装修</h3>
                                        <div style="width: auto;">
                                            <div style="height: auto;" class="cat_table">
                                                <label class="ilabel">
                                                    <label><b><input type="checkbox" id="ckbGoodsListCust"/></b><span style=" font-weight:bold;">底部整体自定义：</span></label><br /> 
                                                    <div style=" padding:5px;" id="divContentTemplatedesc"> 
                                                    <a href="javascript:void(0);return false;" onclick="loadSysContentTemplate();">导入系统模版</a>
                                                    <p>可以在模版中使用javascript代码</p>
                                                    </div>
                                                    </label> 
                                                <div class="list"  style="background-color:#ffffff; ">
                                                <div id="divContentTemplate">
                                                    <textarea name="txtContentTemplate" id="txtContentTemplate" style="width:883px; height: 200px; visibility: hidden;"></textarea>
                                            </div></div>
                                                 
                                            </div>
                                            </div>
                                        <h3>
                                            4.店铺查询页面装修</h3>
                                        <div style="width: auto;">
                                            <div style="height: auto;" class="cat_table">
                                                <label class="ilabel">
                                                    <label><b><input type="checkbox" id="ckbSearchCust"/></b><span style=" font-weight:bold;">底部整体自定义：</span></label><br /> 
                                                    <div style=" padding:5px;" id="divSearchTemplatedesc"> 
                                                    <a href="javascript:void(0);return false;" onclick="loadSysSearchTemplate();">导入系统模版</a>
                                                    <p>可以在模版中使用javascript代码</p>
                                                    </div>
                                                    </label> 
                                                <div class="list"  style="background-color:#ffffff; ">
                                                <div id="divSearchTemplate">
                                                    <textarea name="txtSearchTemplate" id="txtSearchTemplate" style="width:883px; height: 200px; visibility: hidden;"></textarea>
                                            </div></div>
                                                 
                                            </div>
                                        </div>
                                   <%--     <h3>
                                            2.活动信息</h3>
                                        <div style="height: 21px;" class="cat_table">
                                            <label class="ilabel">
                                                <b>*</b>商品送积分：</label><input id="comGoodsPoint" class="sInt1" name="goods.comGoodsPoint"
                                                    value="0" type="text"></div> --%>
                                    </div>
                                </div>



                                    <div style="clear:both; height:20px;"></div>
                                    <div style=" clear:both; margin-top:15px; padding-left:400px; padding-top:15px;"> 
                                        <input class="btn btn-mini btn-danger" id="Button2" type="button" onclick="doSaveSet();" value="保存以上所有配置" />   
                                    </div>



                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- end col-main -->
                    <div class="col-sub" id="J_Col_Sub">
                        <%=new msBsc.WebUi.Code.QtHtmlGet().GetDealerMenu()%>
                    </div>
                    <div style="clear:both;"></div>
                </div>
                <!-- end mytaobao-panel -->
            </div>
        </div>
                    <div style=" clear:both; height:15px;"></div>
        <%=new msBsc.WebUi.Code.QtHtmlGet().GetFloorHtml()%>
    </div>
    <input value="" type="hidden" id="txtId"  name="txtId"/>
    <textarea id="head_img_temp" style="display:none;"> 
            {{# for(var i = 0, len = d.rows.length; i < len; i++){ }}
            <tr data-id="{{ d.rows[i].HEAD_IMG_ID }}">
                <td>
                 <span class="textBox" ><input type="text" class="text" class="need" value="{{ d.rows[i].IMG_URL }}" for="IMG_URL" style="width:300px;"/><a href="javascript:void(0);" class="sel-button head-img-sel"></a></span> 
                </td>
                <td>
                    <input class="need" for="BG_COLOR" value="{{ d.rows[i].BG_COLOR }}" type="text">
                </td>
                <td>
                    <input class="need" for="LINK_URL" value="{{ d.rows[i].LINK_URL }}" type="text"  style="width:200px;">
                </td>
                <td style="border: 0;width:80px;">
                <a style="display: none;" class="spec-remove" href="javascript:void(0);"></a>
                </td>
            </tr>
            {{# }}}
    </textarea> 
    <!-- foot script -->
</body>
</html>
